package main

import (
	"fmt"
	"os"
	"log"
	"github.com/gin-gonic/gin"
	"github.com/liangchao/blogo/src/common/global"
	"github.com/liangchao/blogo/src/common/initialize"
	"github.com/liangchao/blogo/src/web/routers"
)

func init() {
	if dev := os.Getenv("DEV_MOD"); len(dev) > 0 && dev == "true" {
		initialize.InitConfig("conf/dev.app.yaml")
		log.Println("开发环境，DEV_MOD: ", dev)
	} else {
		initialize.InitConfig("conf/pro.app.yaml")
		log.Println("生产环境，DEV_MOD:", dev)
		gin.SetMode(gin.ReleaseMode)
	}


	initialize.InitLogger()

	initialize.InitMysqlDB()
	//
	//initialize.InitRedis()



}

func main() {
	r := gin.Default()

	r.SetTrustedProxies(nil)

	routers.SetupRouter(r)

	r.Run(fmt.Sprintf(":%d", global.Settings.Port))
}
